#ifndef AVOIDANCE_BEHAVIOUR_H_
#define AVOIDANCE_BEHAVIOUR_H_

#include "BehaviourI.h"
#include <float.h>  

/* Itterates over a vector of spherical objects and applies forces away from the nearest.
   Based on parameters, can adjust the heading slightly, or come to a complete stop
*/
class AvoidanceBehaviour : public BehaviourI
{
public:
    AvoidanceBehaviour(): m_wander(NULL){}
    ~AvoidanceBehaviour(){if (m_wander) delete m_wander;}
    virtual void CalcMotion(float* motion, BehaviourInfo* info, float weighting);
    void SetSecondaryBeahviour(BehaviourI* i){m_wander = i;}
private:

    struct AvoidanceCache
    {
        AvoidanceCache() : index(-1),
                           smallestDistance(FLT_MAX),
                           positionLocal(0,0,0)
        {}
        float smallestDistance;
        btVector3 positionLocal;
        int index;
    };
    BehaviourI* m_wander;
};
#endif